/* 
 * FreeModbus Libary: A portable Modbus implementation for Modbus ASCII/RTU.
 * Copyright (c) 2006 Christian Walter <wolti@sil.at>
 * All rights reserved.
 *
 */

#ifndef _MB_APP_H
#define _MB_APP_H

#include "mbcom.h"
#include "mbmaster.h"
#include "mbslave.h"
#include "mbdatacb.h"
#include "mbinputdatacfg.h"
#include "vgus_dev.h"
#include "dgusii_dev.h"
#include "dgus_dev.h"


#ifdef   _MAPP_MODULE_
#define  MAPP_EXT
#else
#define  MAPP_EXT  extern
#endif

#define MBAPP_COM0_EVENT_RTUEND                (1UL<<0)
#define MBAPP_COM0_EVENT_TIMEOUT               (1UL<<1)
#define MBAPP_COM1_EVENT_RTUEND                (1UL<<2)
#define MBAPP_COM1_EVENT_TIMEOUT               (1UL<<3)
#define MBAPP_COM2_EVENT_RTUEND                (1UL<<4)
#define MBAPP_COM2_EVENT_TIMEOUT               (1UL<<5)
#define MBAPP_COM3_EVENT_RTUEND                (1UL<<6)
#define MBAPP_COM3_EVENT_TIMEOUT               (1UL<<7)
#define MBAPP_COM4_EVENT_RTUEND                (1UL<<8)
#define MBAPP_COM4_EVENT_TIMEOUT               (1UL<<9)
#define MBAPP_COM5_EVENT_RTUEND                (1UL<<10)
#define MBAPP_COM5_EVENT_TIMEOUT               (1UL<<11)
#define MBAPP_COM6_EVENT_RTUEND                (1UL<<12)
#define MBAPP_COM6_EVENT_TIMEOUT               (1UL<<13)
#define MBAPP_COM7_EVENT_RTUEND                (1UL<<14)
#define MBAPP_COM7_EVENT_TIMEOUT               (1UL<<15)

#define MBAPP_EVENT_MSK                        0xFFFFUL


typedef struct 
{
    mb_obj_type obj01;
    mb_cmd_buff_type CmdBuff01[32];
    mb_obj_type obj02;
    mb_cmd_buff_type CmdBuff02[32];
} mb_type;

MAPP_EXT mb_type mb;

void mb_os_delay(uint32_t ms);
void mb_os_send(uint16_t event);

void mb00_Init(mb_mode_type mbMode, uint32_t ulBaudRate, mb_parity_type eParity);
void mb00_TimeoutHandle(void);

void mb01_Init(mb_mode_type mbMode, uint32_t ulBaudRate, mb_parity_type eParity);
void mb01_TimeoutHandle(void);

void mb02_Init(mb_mode_type mbMode, uint32_t ulBaudRate, mb_parity_type eParity);
void mb02_TimeoutHandle(void);

void mb03_Init(mb_mode_type mbMode, uint32_t ulBaudRate, mb_parity_type eParity);
void mb03_TimeoutHandle(void);

void mb04_Init(mb_mode_type mbMode, uint32_t ulBaudRate, mb_parity_type eParity);
void mb04_TimeoutHandle(void);

void mb05_Init(mb_mode_type mbMode, uint32_t ulBaudRate, mb_parity_type eParity);
void mb05_TimeoutHandle(void);

void mb06_Init(mb_mode_type mbMode, uint32_t ulBaudRate, mb_parity_type eParity);
void mb06_TimeoutHandle(void);

void mb07_Init(mb_mode_type mbMode, uint32_t ulBaudRate, mb_parity_type eParity);
void mb07_TimeoutHandle(void);


#undef MAPP_EXT

#endif
